package test;

public class ThreadTest2 extends Thread {

  private String tName;

  private String lock;

  public ThreadTest2(String tName, String lock) {
    this.tName=tName;
    this.lock=lock;
  }

  public synchronized static void print(String tName) {
    for(int i=0; i < 100; i++) {
      System.out.println(tName + ":" + i);
    }
  }

  @Override
  public void run() {
    synchronized(lock) {
      for(int i=0; i < 100; i++) {
        System.out.println(tName + ":" + i);
      }
    }
    // print(tName);
  }

  public static void main(String[] args) {
    String lock=new String("lock");
    for(int i=100; i < 200; i++) {
      new ThreadTest2(i + "", lock).start();
    }
  }
}
